<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
//设置页面不缓存
	response.setHeader("Pragma", "No-cache");
	response.setHeader("Cache-Control", "no-cache");
	response.setDateHeader("Expires", 0);
	
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	String size = request.getParameter("size");
	String action = request.getParameter("action");//添加商品还是修改商品
	String type = request.getParameter("type");//goods 还是团购商品
	String random = request.getParameter("random"); //生成的随机数
	String imagePath = request.getParameter("imagePath");
	String temp[] = imagePath.split("/");
	String imageName =  temp[temp.length-1];
	System.out.println(imageName+"----name");
	int height = 120;
	int width = 160;
	if ("16".equals(size)) {
		height = 90;
		width = 160;
	} else if ("9".equals(size)) {
		height = 160;
		width = 90;
	} else if ("4".equals(size)) {
		height = 120;
		width = 160;
	} else if ("3".equals(size)) {
		height = 160;
		width = 120;
	}
%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">
<title>图片上传</title>

<style>
body {
	color: #333;
	background: white;
	margin-left: 20px;
}

*,body {
	font-family: Arial, Helvetica, sans-serif;
	line-height: 30px;
	font-family: verdana;
	color: #333;
	border: 0px;
	padding: 0px;
}

h1,h3 {
	margin: 15px 0 5px 0;
	padding: 0;
	font-size: 17px;
	font-family: microsoft yahei;
	font-weight: normal;
	border-bottom: 1px solid #CCC;
}

span {
	color: #f30;
	margin: 0 4px;
}
</style>
<script type="text/javascript" src="<%=basePath%>js/jquery.min.js"></script>
<!--放入项目中 start -->
<script type="text/javascript">
	function uploadevent(result) {
		result+="";
		switch (result) {
		case "1":
			if($("#action").html()=="change"){
				if(confirm("商品图片已更新！！！,需要关闭该页面吗？")){
					window.opener.parent.location.reload(true);
					self.close();
				}
			}else{
				if(confirm("商品图片已上传！！！,需要关闭该页面吗？")){
					window.opener.parent.$("#GoodsImgText").val("图片已上传<%=imagePath%>");
					self.close();
				}
			}
			break;
		case "-1":
			window.location.reload();
			break;
		default:
			window.location.reload();
	}
}


function ref(value){
	var height = 120;
	var width = 160;
	if ("16"==value) {
		height = 90;
		width = 160;
	} else if ("9"==value) {
		height = 160;
		width = 90;
	} else if ("4"==value) {
		height = 120;
		width = 160;
	} else if ("3"==value) {
		height = 160;
		width = 120;
	}
	
	//window.location.href = "index.jsp?size="+value;
	var html = "<OBJECT classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0\""
		+" WIDTH=\"650\" HEIGHT=\"450\" id=\"myMovieName\"><PARAM NAME=movie VALUE=\"_seller/avatar.swf\" /><PARAM NAME=quality VALUE=high />"
		+" <PARAM NAME=bgcolor VALUE=#FFFFFF /><param name=\"flashvars\""
		+" value=\"imgUrl=<%=imagePath%>&uploadUrl=servlet/UploadImgServlet?params=<%=action%>,<%=type%>,<%=imageName%>,<%=random%>&uploadSrc=false&pSize="+width+"|"+height+"|"+width/3+"|"+height/3+"|"+width/4+"|"+height/4+"\" />"
		+" <EMBED src=\"_seller/avatar.swf\" quality=high bgcolor=#FFFFFF WIDTH=\"650\""
		+" HEIGHT=\"450\" wmode=\"transparent\" flashVars=\"imgUrl=<%=imagePath%>&uploadUrl=servlet/UploadImgServlet?params=<%=action%>,<%=type%>,<%=imageName%>,<%=random%>&uploadSrc=false&pSize="+width+"|"+height+"|"+width/3+"|"+height/3+"|"+width/4+"|"+height/4+"\""
		+" NAME=\"myMovieName\" ALIGN=\"\" TYPE=\"application/x-shockwave-flash\" allowScriptAccess=\"always\""
		+" PLUGINSPAGE=\"http://www.macromedia.com/go/getflashplayer\"> </EMBED></OBJECT>\"";
	$("#flash").html(html);
}
</script>
<!--放入项目中 start -->
</head>

<body>

	<div style="display: none;" id="action"><%=action%></div>
	<h1>Flash头像上传组件</h1>
	<button onclick="ref(16)">16:9</button>
	<button onclick="ref(9)">9:16</button>
	<button onclick="ref(4)">4:3</button>
	<button onclick="ref(3)">3:4</button>
<div id="flash">
	<!--放入项目中 start -->
	<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
		codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"
		WIDTH="650" HEIGHT="450" id="myMovieName">
		<PARAM NAME=movie VALUE="_seller/avatar.swf" />
		<PARAM NAME=quality VALUE=high />
		<PARAM NAME=bgcolor VALUE=#FFFFFF />
		<param name="flashvars"
			value="imgUrl=<%=imagePath%>&uploadUrl=servlet/UploadImgServlet?params=<%=action%>,<%=type%>,<%=imageName%>,<%=random%>&uploadSrc=false&pSize=<%=width%>|<%=height%>|<%=width / 3%>|<%=height / 3%>|<%=width / 4%>|<%=height / 4%>" />
		<EMBED src="_seller/avatar.swf" quality=high bgcolor=#FFFFFF WIDTH="650"
			HEIGHT="450" wmode="transparent"
			flashVars="imgUrl=<%=imagePath%>&uploadUrl=servlet/UploadImgServlet?params=<%=action%>,<%=type%>,<%=imageName%>,<%=random%>&uploadSrc=false&pSize=<%=width%>|<%=height%>|<%=width / 3%>|<%=height / 3%>|<%=width / 4%>|<%=height / 4%>"
			NAME="myMovieName" ALIGN="" TYPE="application/x-shockwave-flash"
			allowScriptAccess="always"
			PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"> </EMBED>
	</OBJECT>
	<!--放入项目中 end -->

</div>
</body>
</html>